home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Email Clients / Talk-n-Mail.exe / _SETUP.1 / $TNM$_Main.js < prev    next >
Encoding:
JavaScript  |  2001-04-22  |  5.8 KB  |  321 lines

  1. /*     JavaScript for Talk-n-Mail
  2.     Copyright (c) 1999-2000, SoftApproach Corp. All rights reserved
  3. */
  4.  
  5. var CONST_COOKIE_NULL = '_NULL'
  6. var ibReloaded = false
  7. var ibIsIE
  8. var iiPageWidth
  9.  
  10. /* Show/Hide object */
  11. function fvShow(asObject, abShow)
  12. {
  13. var lsTmp
  14. var lObj
  15.  
  16.     if(ibIsIE)
  17.     {
  18.         if(abShow)
  19.             lsTmp = "visible"
  20.         else
  21.             lsTmp = "hidden"
  22.         // End if
  23.     }
  24.     else
  25.     {
  26.  
  27.         if(abShow)
  28.             lsTmp = "show"
  29.         else
  30.             lsTmp = "hide"
  31.         // End if
  32.     }
  33.  
  34.     lObj = fobjGetDivObjectByName(asObject)
  35.     lObj.visibility = lsTmp
  36.  
  37. }
  38.  
  39. // Returns one of the frames or background
  40. // for attributes
  41. function fobjGetDivObject(aiIndex)
  42. {
  43. var lsName
  44.  
  45.     lsName = fsGetDivName(aiIndex)
  46.     return fobjGetDivObjectByName(lsName)
  47. }
  48.  
  49. function fsGetDivName(aiIndex)
  50. {
  51.     if(iarAniDivData[iarAniDivData.iIndex].bHasBackground)
  52.         return "div" + aiIndex
  53.     else
  54.         return "div" + aiIndex + "Frame0"
  55.     // End if
  56. }
  57.  
  58.  
  59. /* Center one object */
  60. function fvCenterObject(asObject)
  61. {
  62. var lobjTmp
  63.  
  64.     if(ibIsIE)
  65.     {
  66.         lobjTmp = document.all[asObject].style
  67.  
  68.         // Use parseInt() to get rid of the px sufix
  69.         lobjTmp.left = (fiPageWidth() -
  70.             parseInt(lobjTmp.width)) / 2
  71.     }
  72.     else
  73.     {
  74.         lobjTmp = document.layers[asObject]
  75.         // Width and Height are not available in Netscape Layer
  76.         lobjTmp.left = (fiPageWidth() - lobjTmp.clip.width) / 2
  77.     }
  78.  
  79. }
  80.  
  81. function fiPageWidth()
  82. {
  83.     if(ibIsIE)
  84.         return parseInt(document.body.offsetWidth)
  85.     else
  86.         return window.innerWidth
  87.     // End if
  88. }
  89.  
  90.  
  91.  
  92. function fvResize()
  93. {
  94.  
  95.     // Center Objects
  96.     if(iiPageWidth != fiPageWidth())
  97.     {
  98.         // Reload
  99.         if(!ibIsIE)
  100.         {
  101.             bReloaded = !bReloaded
  102.             if(!bReloaded)
  103.                 document.location.href = document.location.href
  104.             // End if
  105.         }
  106.  
  107.         fvCenterObject("divPage")
  108.         fvCenterObject("divButtons1")
  109.                 fvCenterObject("divButtons2")
  110.  
  111.         fvCenterObject("divSound")
  112.         fvCenterObject("divTitleFrame1")
  113.         fvCenterObject("divTitleFrame2")
  114.  
  115.         // Keep the new size
  116.         iiPageWidth = fiPageWidth()
  117.  
  118.     }
  119. }
  120.  
  121. // Call myself periodically to check the window resize
  122. // Netscape disables onResize event once embedded sound is added
  123. function fvTimer()
  124. {
  125.     fvResize()
  126.     setTimeout("fvTimer()", 1000)
  127. }
  128.  
  129. function fiGetSubStringPos(asString, asSubString, abCaseSensitive)
  130. {
  131. // Return: 0 - n, -1 = not found
  132. var lsString
  133. var lsSubString
  134.  
  135.     lsString = new String(asString)
  136.     lsSubString = new String(asSubString)
  137.  
  138.     if(!abCaseSensitive)
  139.     {
  140.         lsString.toLowerCase()
  141.         lsSubString.toLowerCase()
  142.     }
  143.  
  144.     return lsString.indexOf(lsSubString)
  145. }
  146.  
  147. function fobjGetDivObjectByName(asName)
  148. {
  149. var lsNameRoot
  150.     if(ibIsIE)
  151.     {
  152.         return document.all[asName].style
  153.     }
  154.     else
  155.     {
  156.         lObj = document.divPage.layers[asName]
  157.         if(lObj) return lObj
  158.  
  159.         lObj = document.layers[asName]
  160.         if(lObj) return lObj
  161.  
  162.         alert("Name not found: " + asName)
  163.     }// End if
  164. }
  165.  
  166. function fvInit()
  167. {
  168.  
  169.     ibIsIE = (document.layers) ? false : true
  170.  
  171.     // Center me for the first time Need to init the values
  172.     iiPageWidth = 0
  173.     fvResize()
  174.  
  175.     // Error handler
  176.     window.onerror = fvWindowErrorHandler
  177.  
  178.     // Netscape?
  179.     if(!ibIsIE)
  180.     {
  181.  
  182.         fvTimer()
  183.     }
  184.  
  185.     // Show all objects
  186.     fvShow("divPage", true)
  187.     fvShow("divButtons1", true)
  188.     fvShow("divSound", true)
  189.  
  190.     // Page animation
  191.     fvAniInit()
  192. }
  193.  
  194. /* Get a value */
  195. function fsGetCookie(sName)
  196. {
  197. var iOffset
  198. var iEnd
  199. var sSearch = sName + "="
  200. var lsValue
  201.  
  202.    // if there are any cookies
  203.    if (document.cookie.length > 0)
  204.    {
  205.       iOffset = document.cookie.indexOf(sSearch)
  206.  
  207.       // if cookie exists
  208.       if (iOffset != -1) {
  209.          iOffset += sSearch.length
  210.  
  211.          // set index of beginning of sValue
  212.          iEnd = document.cookie.indexOf(";", iOffset)
  213.  
  214.          // set index of iEnd of cookie sValue
  215.          if (iEnd == -1)
  216.             iEnd = document.cookie.length
  217.  
  218.     lsValue = unescape(document.cookie.substring(iOffset, iEnd))
  219.     if(lsValue == CONST_COOKIE_NULL){lsValue = ''}
  220.         return lsValue
  221.       }
  222.    }
  223. }
  224.  
  225. /* Sets cookie values. Expiration date is optional: To keep the cookie for 
  226. later sessions */
  227. function fvSetCookie(sName, sValue, dtExpire)
  228. {
  229.         sValue = escape(sValue)
  230.     // undefined var will erase the entire entry in NC
  231.     if(sValue == null || sValue == '' || sValue == 'undefined'){sValue = 
  232. CONST_COOKIE_NULL}
  233.         if(dtExpire != null)
  234.     {
  235.         sValue += "; expires="
  236.  
  237.         // IE
  238.         if(document.all)
  239.         {
  240.             sValue += dtExpire.toGMTString()}
  241.         // NC
  242.         else
  243.         {
  244.             sValue += fsToCookieDate(dtExpire)
  245.         }
  246.     }
  247.         document.cookie = sName + "=" + sValue
  248. }
  249.  
  250. // For NC, otherwise toGMTString() is good enough
  251. // Officially: 'Sunday, 06-Jan-01 23:12:40 GMT'
  252. // Tested: '06-01-01 23:12:40 GMT'
  253. function fsToCookieDate(dtDate)
  254. {
  255. var lsDate = ''
  256.  
  257.     lsDate += fsNumber2String(dtDate.getDate()) + "-"
  258.     lsDate += fsNumber2String(dtDate.getMonth() + 1) + "-"
  259.     lsDate += fsNumber2String(dtDate.getYear() + 1) + " "
  260.     lsDate += fsNumber2String(dtDate.getHours()) + ":"
  261.     lsDate += fsNumber2String(dtDate.getMinutes()) + ":"
  262.     lsDate += fsNumber2String(dtDate.getSeconds()) + " GMT"
  263.  
  264.     return lsDate
  265. }
  266. // Return a 2 byte string
  267. function fsNumber2String(alValue)
  268. {
  269.     return alValue < 10 ? '0' + alValue : alValue
  270. }
  271.  
  272. function LTrim(String)
  273. {
  274. var i = 0
  275. var j = String.length - 1
  276.  
  277. if (!String) return ''
  278.  
  279. for (i = 0; i < String.length; i++)
  280. {
  281.     if (String.substr(i, 1) != ' ' &&
  282.         String.substr(i, 1) != '\t')
  283.             break;
  284. }
  285.  
  286. if (i <= j)
  287.     return (String.substr(i, (j+1)-i));
  288. else
  289.     return '';
  290. }
  291.  
  292. function RTrim(String)
  293. {
  294. var i = 0
  295. var j = String.length - 1
  296.  
  297. if (!String) return ''
  298.  
  299. for(j = String.length - 1; j >= 0; j--)
  300. {
  301.     if (String.substr(j, 1) != ' ' &&
  302.         String.substr(j, 1) != '\t')
  303.     break;
  304. }
  305.  
  306.     if (i <= j)
  307.         return (String.substr(i, (j+1)-i));
  308.     else
  309.         return '';
  310. }
  311.  
  312. function Trim(String)
  313. {
  314.     if (String == null)
  315.         return '';
  316.  
  317.     return RTrim(LTrim(String));
  318. }
  319.  
  320.  
  321.